package top.lfyao.designpattern.details.iterator;



/**
 * 迭代器客户端

 */
public class IteratorClient {
    public static void main(String[] args){

     /*   ConcreteAggregate<Integer> in = new ConcreteAggregate<>();
        in.setItems(1);
        in.setItems(2);
        in.setItems(3);
        in.setItems(4);
        ConcreteIterator<Integer> integerConcreteIterator = new ConcreteIterator<>(in);
*/

        ConcreteAggregate<String> bus = new ConcreteAggregate<String>();

        bus.setItems("大鸟");
        bus.setItems("小菜");
        bus.setItems("行李");
        bus.setItems("老外");
        bus.setItems("公交内部员工");
        bus.setItems("小偷");

        Iterator<String> iterator = new ConcreteIterator<>(bus);

        while (iterator.isDone()) {
            System.out.println(iterator.currentItem() + "请买票！");
            iterator.next();
        }

    }
}
